<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AI应用统计 - 公文写作</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <style>
      /*  * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
        }

        body {
            background-color: #f5f7fa;
            color: #333;
            line-height: 1.6;
        }

        .stats-container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }

        .stats-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 30px;
            padding-bottom: 15px;
            border-bottom: 1px solid #e1e4e8;
        }

        .stats-title {
            display: flex;
            align-items: center;
        }

        .stats-icon {
            width: 50px;
            height: 50px;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 15px;
            background-color: #e0f7fa;
        }

        .stats-icon i {
            font-size: 24px;
            color: #00acc1;
        }

        .stats-name h2 {
            font-size: 24px;
            font-weight: 600;
            margin-bottom: 5px;
        }

        .stats-name p {
            color: #666;
            font-size: 14px;
        }

        .stats-actions {
            display: flex;
            gap: 10px;
        }

        .btn {
            padding: 8px 16px;
            border-radius: 6px;
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            border: 1px solid transparent;
            transition: all 0.3s ease;
        }

        .btn-outline {
            background-color: transparent;
            border-color: #d1d5da;
            color: #24292e;
        }

        .btn-outline:hover {
            background-color: #f6f8fa;
        }

        .btn-primary {
            background-color: #2188ff;
            color: white;
            border-color: #2188ff;
        }

        .btn-primary:hover {
            background-color: #0d7ae5;
            border-color: #0d7ae5;
        }

        .stats-period {
            display: flex;
            justify-content: space-between;
            margin-bottom: 20px;
            align-items: center;
        }

        .period-selector {
            display: flex;
            gap: 10px;
        }

        .period-btn {
            padding: 6px 12px;
            border-radius: 6px;
            font-size: 14px;
            background-color: transparent;
            border: 1px solid #d1d5da;
            cursor: pointer;
        }

        .period-btn.active {
            background-color: #2188ff;
            color: white;
            border-color: #2188ff;
        }

        .date-range {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .date-input {
            padding: 6px 12px;
            border-radius: 6px;
            border: 1px solid #d1d5da;
            font-size: 14px;
        }

        .stats-grid {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 20px;
            margin-bottom: 30px;
        }

        .stat-card {
            background-color: white;
            border-radius: 10px;
            padding: 20px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
        }

        .stat-card h3 {
            font-size: 14px;
            color: #666;
            margin-bottom: 10px;
            font-weight: 500;
        }

        .stat-value {
            font-size: 28px;
            font-weight: 600;
            margin-bottom: 5px;
        }

        .stat-change {
            font-size: 12px;
            display: flex;
            align-items: center;
        }

        .stat-change.up {
            color: #28a745;
        }

        .stat-change.down {
            color: #dc3545;
        }

        .stat-change i {
            margin-right: 3px;
        }

        .chart-container {
            background-color: white;
            border-radius: 10px;
            padding: 20px;
            margin-bottom: 30px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
        }

        .chart-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }

        .chart-title {
            font-size: 18px;
            font-weight: 600;
        }

        .chart-toggle {
            display: flex;
            gap: 10px;
        }

        .chart-toggle-btn {
            padding: 6px 12px;
            border-radius: 6px;
            font-size: 14px;
            background-color: transparent;
            border: 1px solid #d1d5da;
            cursor: pointer;
        }

        .chart-toggle-btn.active {
            background-color: #2188ff;
            color: white;
            border-color: #2188ff;
        }

        .chart-wrapper {
            position: relative;
            height: 300px;
        }

        .chart-actions {
            display: flex;
            justify-content: flex-end;
            margin-top: 15px;
            gap: 10px;
        }

        .chart-action-btn {
            padding: 4px 8px;
            font-size: 12px;
            background-color: transparent;
            border: 1px solid #d1d5da;
            border-radius: 4px;
            cursor: pointer;
        }

        .stats-table-container {
            background-color: white;
            border-radius: 10px;
            padding: 20px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
        }

        .table-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }

        .table-title {
            font-size: 18px;
            font-weight: 600;
        }

        .export-btn {
            padding: 6px 12px;
            border-radius: 6px;
            font-size: 14px;
            background-color: transparent;
            border: 1px solid #d1d5da;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 5px;
        }

        table {
            width: 100%;
            border-collapse: collapse;
        }

        th, td {
            padding: 12px 15px;
            text-align: left;
            border-bottom: 1px solid #e1e4e8;
        }

        th {
            font-weight: 600;
            color: #666;
            font-size: 14px;
        }

        td {
            font-size: 14px;
        }

        .user-cell {
            display: flex;
            align-items: center;
        }

        .user-avatar {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            background-color: #e1e4e8;
            margin-right: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #666;
            font-size: 14px;
        }

        .status-badge {
            padding: 4px 8px;
            border-radius: 12px;
            font-size: 12px;
            font-weight: 500;
        }

        .status-badge.success {
            background-color: #d4edda;
            color: #155724;
        }

        .status-badge.warning {
            background-color: #fff3cd;
            color: #856404;
        }

        .status-badge.error {
            background-color: #f8d7da;
            color: #721c24;
        }

        .pagination {
            display: flex;
            justify-content: center;
            margin-top: 30px;
            gap: 5px;
        }

        .page-btn {
            width: 36px;
            height: 36px;
            border-radius: 6px;
            display: flex;
            align-items: center;
            justify-content: center;
            border: 1px solid #d1d5da;
            background-color: white;
            cursor: pointer;
        }

        .page-btn.active {
            background-color: #2188ff;
            color: white;
            border-color: #2188ff;
        }

        .page-btn.disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        .page-ellipsis {
            display: flex;
            align-items: center;
            padding: 0 10px;
        }

        .error-details {
            display: none;
            margin-top: 20px;
            padding: 15px;
            background-color: #f8f9fa;
            border-radius: 6px;
            border-left: 4px solid #dc3545;
        }

        .error-details h4 {
            margin-bottom: 10px;
            color: #dc3545;
        }

        .error-details pre {
            background-color: white;
            padding: 10px;
            border-radius: 4px;
            overflow-x: auto;
            font-size: 13px;
        }*/
    </style>
</head>
<body>
<div class="stats-container">
    <div class="stats-header">
        <div class="stats-title">
            <div class="stats-icon">
                <i class="fas fa-file-contract"></i>
            </div>
            <div class="stats-name">
                <h2>公文写作</h2>
                <p>根据模板和关键词自动生成公文初稿</p>
            </div>
        </div>
        <div class="stats-actions">
            <button class="btn btn-outline" id="backBtn">
                <i class="fas fa-arrow-left"></i> 返回
            </button>
            <button class="btn btn-primary" id="exportReportBtn">
                <i class="fas fa-download"></i> 导出报表
            </button>
        </div>
    </div>

    <div class="stats-period">
        <div class="period-selector">
            <button class="period-btn" data-period="day">今日</button>
            <button class="period-btn" data-period="week">本周</button>
            <button class="period-btn active" data-period="month">本月</button>
            <button class="period-btn" data-period="quarter">本季</button>
            <button class="period-btn" data-period="year">本年</button>
        </div>
        <div class="date-range">
            <input type="date" class="date-input" id="startDate">
            <span>至</span>
            <input type="date" class="date-input" id="endDate">
            <button class="btn btn-outline" id="applyDateBtn">应用</button>
        </div>
    </div>

    <div class="stats-grid">
        <div class="stat-card">
            <h3>总调用量</h3>
            <div class="stat-value" id="totalCalls">1,042</div>
            <div class="stat-change up">
                <i class="fas fa-arrow-up"></i> <span id="totalChange">12.5%</span> 较上月
            </div>
        </div>
        <div class="stat-card">
            <h3>成功次数</h3>
            <div class="stat-value" id="successCalls">998</div>
            <div class="stat-change up">
                <i class="fas fa-arrow-up"></i> <span id="successChange">8.3%</span> 较上月
            </div>
        </div>
        <div class="stat-card">
            <h3>失败次数</h3>
            <div class="stat-value" id="failedCalls">44</div>
            <div class="stat-change down">
                <i class="fas fa-arrow-down"></i> <span id="failedChange">3.2%</span> 较上月
            </div>
        </div>
        <div class="stat-card">
            <h3>平均响应时间</h3>
            <div class="stat-value" id="avgResponse">1.2s</div>
            <div class="stat-change down">
                <i class="fas fa-arrow-down"></i> <span id="responseChange">0.3s</span> 较上月
            </div>
        </div>
    </div>

    <div class="chart-container">
        <div class="chart-header">
            <div class="chart-title">调用量趋势</div>
            <div class="chart-toggle">
                <button class="chart-toggle-btn" data-type="day">日</button>
                <button class="chart-toggle-btn" data-type="week">周</button>
                <button class="chart-toggle-btn active" data-type="month">月</button>
            </div>
        </div>
        <div class="chart-wrapper">
            <canvas id="usageTrendChart"></canvas>
        </div>
        <div class="chart-actions">
            <button class="chart-action-btn" id="exportTrendImage">
                <i class="fas fa-image"></i> 导出图片
            </button>
            <button class="chart-action-btn" id="exportTrendData">
                <i class="fas fa-file-csv"></i> 导出数据
            </button>
            <button class="chart-action-btn" id="fullscreenTrend">
                <i class="fas fa-expand"></i> 全屏
            </button>
        </div>
    </div>

    <div class="chart-container">
        <div class="chart-header">
            <div class="chart-title">响应时间分布</div>
            <div class="chart-toggle">
                <button class="chart-toggle-btn active" data-type="success">成功率</button>
                <button class="chart-toggle-btn" data-type="time">响应时间</button>
                <button class="chart-toggle-btn" data-type="error">错误类型</button>
            </div>
        </div>
        <div class="chart-wrapper">
            <canvas id="responseChart"></canvas>
        </div>
        <div class="chart-actions">
            <button class="chart-action-btn" id="exportResponseImage">
                <i class="fas fa-image"></i> 导出图片
            </button>
            <button class="chart-action-btn" id="exportResponseData">
                <i class="fas fa-file-csv"></i> 导出数据
            </button>
            <button class="chart-action-btn" id="fullscreenResponse">
                <i class="fas fa-expand"></i> 全屏
            </button>
        </div>
    </div>

    <div class="stats-table-container">
        <div class="table-header">
            <div class="table-title">最近调用记录</div>
            <button class="export-btn" id="exportCsvBtn">
                <i class="fas fa-download"></i> 导出CSV
            </button>
        </div>
        <table>
            <thead>
            <tr>
                <th>时间</th>
                <th>用户</th>
                <th>操作类型</th>
                <th>响应时间</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody id="callRecords">
            <!-- 记录将通过JavaScript动态生成 -->
            </tbody>
        </table>

        <div id="errorDetailContainer" class="error-details">
            <h4>错误详情</h4>
            <pre id="errorDetailContent"></pre>
        </div>

        <div class="pagination">
            <button class="page-btn disabled" id="prevPageBtn">
                <i class="fas fa-angle-left"></i>
            </button>
            <button class="page-btn active">1</button>
            <button class="page-btn">2</button>
            <button class="page-btn">3</button>
            <span class="page-ellipsis">...</span>
            <button class="page-btn">5</button>
            <button class="page-btn" id="nextPageBtn">
                <i class="fas fa-angle-right"></i>
            </button>
        </div>
    </div>
</div>
</body>
</html>